package cn.huas.util;

import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;

public class ActionContextUtil {
	public static HttpServletRequest	request;	
	public static ActionContext context;
	public static HttpServletResponse response;
	public static ActionContext getActionContext(){
		context = ActionContext.getContext();
		return context;
	}
	
	public static HttpServletRequest getHttpServletRequest(){
		request = (HttpServletRequest) getActionContext().get(ServletActionContext.HTTP_REQUEST);
		try {
			request.setCharacterEncoding("utf-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return request;
	}
	
	public static HttpServletResponse getHttpServletResponse(){
		response = (HttpServletResponse) context.get(ServletActionContext.HTTP_RESPONSE);
		response.setCharacterEncoding("utf-8");
		return response;
	}
	 
}
